<% javascript_tag do %>
var selectedPrize = null;
function selectPrize(dom,prizeID) {
  if(selectedPrize) {
    selectedPrize.removeClassName("prize-selected");
  }
  dom.addClassName("prize-selected");
  selectedPrize = dom;
  $("selected-prize-id").setValue(prizeID);
  submitSelectPrizeForm();
}

function submitSelectPrizeForm() {
  var prizeID = $("selected-prize-id").getValue();
  if(prizeID == "" || !prizeID) {
    new Dialog().showMessage('Please select','Select a prize.');
  } else {
    $("select-prize-form").submit();
  }
}

function showSelectPrizeForm(){
  $("select-prize-form").setStyle({"display":"block"});
}


<% end %>

<div class="prizes clear" id="prizes">
<%= render :partial=>"prizes/prize",:collection=>Prize.all %>
</div>
